//代理模式
const start = {
  name: 'start',
  age: 18,
  phone: 199999999
}
const agent = new Proxy(start, {
  get(target, key) {
    if (key === 'phone') {
      return '**** **** ****'
    } else {
      return Reflect.get(target, key)
    }
  },
  set(target, key, value) {
    if (key === 'age' && value < 18) {
      throw new Error('too young')
    } else {
      return Reflect.set(target, key, value)
    }
  }
})

console.log(agent.name, agent.age, agent.phone)
agent.age = 10
agent.phone = 199999999
